----------------------------------------------------------------
-- Global Variables
----------------------------------------------------------------

LayoutUtils = {}

-- Sizes the window to fit the Icon's aspect ratio
function LayoutUtils.SizeImageForIcon( iconWindow, iconSize, iconId ) 

    -- Set the Icon.. (Scale it if needed )
    local texture, textureX, textureY, sizeX, sizeY, colorR, colorG, colorB  = GetMapIconData( iconId )    

    DynamicImageSetTexture( iconWindow, texture, textureX, textureY )   
    WindowSetTintColor( iconWindow, colorR, colorG, colorB )    
    
    DynamicImageSetTextureDimensions( iconWindow, sizeX, sizeY )    
    
    local xScale = iconSize/sizeX;
    local yScale = iconSize/sizeY;
    
    if( xScale > yScale ) then
        WindowSetDimensions( iconWindow, iconSize, iconSize*(xScale/yScale))
    else        
        WindowSetDimensions( iconWindow, iconSize*(yScale/xScale), iconSize)
    end
    
end